package cn.wildfire.chat.app.extendsion.classes;

import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;

/**
 * Create by HEKE, 2019/8/16 16:28
 * TODO 国家区号对象
 */
public class Region implements Parcelable {

    public String createTime;
    public int deleted;
    public int id;
    public int pid;
    public String regionCode;
    public String regionName;
    public String regionShortName;
    public String updateTime;

    public Region() {
        super();
    }

    public Region(@NonNull String simpleString) {
        String[] array = simpleString.split("[,]");
        this.id = Integer.parseInt(array[0]);
        this.regionCode = array[1];
        this.regionName = array[2];
    }

    public Region(int id, String regionCode, String regionName) {
        this.id = id;
        this.regionCode = regionCode;
        this.regionName = regionName;
    }

    protected Region(Parcel in) {
        createTime = in.readString();
        deleted = in.readInt();
        id = in.readInt();
        pid = in.readInt();
        regionCode = in.readString();
        regionName = in.readString();
        regionShortName = in.readString();
        updateTime = in.readString();
    }

    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeString(createTime);
        dest.writeInt(deleted);
        dest.writeInt(id);
        dest.writeInt(pid);
        dest.writeString(regionCode);
        dest.writeString(regionName);
        dest.writeString(regionShortName);
        dest.writeString(updateTime);
    }

    public String toSimpleString() {
        return id + "," + regionCode + "," + regionName;
    }

    @NonNull
    @Override
    public String toString() {
        return createTime + "," + deleted + "," + id + "," + pid + "," + regionCode + "," + regionName + "," + regionShortName + "," + updateTime;
    }

    @Override
    public int describeContents() {
        return 0;
    }

    public static final Creator<Region> CREATOR = new Creator<Region>() {
        @Override
        public Region createFromParcel(Parcel in) {
            return new Region(in);
        }

        @Override
        public Region[] newArray(int size) {
            return new Region[size];
        }
    };

}
